<?php

namespace HelloWeb\LottoBundle\Controller;

use Library\BaseController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use HelloWeb\LottoBundle\Form\LottoForm;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class LottoController extends BaseController
{
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();
        $lottos = $em->getRepository('HelloWebLottoBundle:Lotto')->fetchAll();
        return $this->render('HelloWebLottoBundle:Lotto:index.html.twig', array(
            'lottos'=>$lottos
        ));
    }
    
    public function addAction(Request $request){
        return $this->editAction($request);
    }
    
    public function editAction(Request $request){
        $form = $this->createForm(new LottoForm());
        return $this->render('HelloWebLottoBundle:Lotto:edit.html.twig',array(
            'form'=>$form->createView()
        ));
    }
}
